home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / programer2 / pari2 / pari / c / anal < prev    next >
Text File  |  1991-12-07  |  43KB  |  1,396 lines

  1. /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
  2. /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
  3. /*                                                                 */
  4. /*            Analyseur syntactique pour la calculette             */
  5. /*                                                                 */
  6. /*                       copyright Babe Cool                       */
  7. /*                                                                 */
  8. /*                                                                 */
  9. /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
  10. /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
  11.  
  12. #include "genpari.h"
  13.  
  14. GEN seq(), expr(), exprcomp(), expradd(), terme(), facteur();
  15. GEN truc(), identifier(), constante();
  16. void skipseq(), skipexpr(), skipexprcomp(), skipexpradd(), skipterme();
  17. void skipfacteur(), skiptruc(), skipconstante(), skipidentifier();
  18. entree *findentry(), *skipentry();
  19.  
  20. static char *analyseurs,*labellist[100];
  21. static long analyseurtetpil;
  22.  
  23. GEN lisexpr(t)
  24.      char *t;
  25.      
  26. {
  27.   GEN res;
  28.   long av, oldtetpil = analyseurtetpil;
  29.   char *olds = analyseurs;
  30.   analyseurs = t; analyseurtetpil = av = avma;
  31.   res = expr();
  32.   res = gerepile(av, analyseurtetpil, res);      
  33.   analyseurtetpil = oldtetpil; analyseurs = olds;
  34.   return res;
  35. }
  36.  
  37. GEN readexpr(c)
  38.      char **c;
  39. {
  40.   char *olds = analyseurs, *oldc = *c;
  41.   analyseurs = oldc; skipexpr();
  42.   if ((*analyseurs) && !separe(*analyseurs)) err(caracer1, analyseurs);
  43.   *c = analyseurs; analyseurs = olds;
  44.   return lisexpr(oldc);
  45. }
  46.  
  47. GEN lisseq(t)
  48.      char *t;
  49. {
  50.   GEN res;
  51.   long av, oldtetpil = analyseurtetpil;
  52.   char *olds = analyseurs;
  53.   analyseurs = t; analyseurtetpil = av = avma;
  54.   res = seq();
  55.   res = gerepile(av, analyseurtetpil, res);      
  56.   analyseurtetpil = oldtetpil; analyseurs = olds;
  57.   return res;
  58. }
  59.  
  60. GEN readseq(c)
  61.      char **c;
  62. {
  63.   long i;
  64.   char *olds = analyseurs, *oldc = *c;
  65.   for(i=0;i<100;i++) labellist[i]=(char*)0;
  66.   analyseurs = oldc; skipseq();
  67.   *c = analyseurs; analyseurs = olds;
  68.   return lisseq(oldc);
  69. }
  70.  
  71. entree fonctions[]={
  72.   {"O",50,0,0},
  73.   {"abs",1,(void *)gabs,0},
  74.   {"acos",1,(void *)gacos,0},
  75.   {"acosh",1,(void *)gach,0},
  76.   {"addell",3,(void *)addell,0},
  77.   {"adj",1,(void *)adj,0},
  78.   {"agm",2,(void *)agm,0},
  79.   {"algdep",23,(void *)algdep,0},
  80.   {"algdep2",33,(void *)algdep2,0},
  81.   {"anell",23,(void *)anell,0},
  82.   {"apell",2,(void *)apell,0},
  83.   {"apell2",2,(void *)apell2,0},
  84.   {"apprpadic",2,(void *)apprgen9,0},
  85.   {"arg",1,(void *)garg,0},
  86.   {"asin",1,(void *)gasin,0},
  87.   {"asinh",1,(void *)gash,0},
  88.   {"assmat",1,(void *)assmat,0},
  89.   {"atan",1,(void *)gatan,0},
  90.   {"atanh",1,(void *)gath,0},
  91.   {"base",13,(void *)base,0},
  92.   {"bernreal",11,(void *)bernreal,0},
  93.   {"bernvec",11,(void *)bernvec,0},
  94.   {"bezout",2,(void *)vecbezout,0},
  95.   {"bigomega",10,(void *)bigomega,0},
  96.   {"bin",21,(void *)binome,0},
  97.   {"binary",1,(void *)binaire,0},
  98.   {"bittest",29,(void *)bittest,0},
  99.   {"boundcf",21,(void *)gboundcf,0},
  100.   {"boundfact",21,(void *)boundfact,0},
  101.   {"ceil",1,(void *)gceil,0},
  102.   {"centerlift",1,(void *)centerlift,0},
  103.   {"cf",1,(void *)gcf,0},
  104.   {"cf2",2,(void *)gcf2,0},
  105.   {"changevar",2,(void *)changevar,0},
  106.   {"char",14,(void *)caradj0,0},
  107.   {"char1",14,(void *)caract,0},
  108.   {"char2",14,(void *)carhess,0},
  109.   {"chell",2,(void *)coordch,0},
  110.   {"chinese",2,(void *)chinois,0},
  111.   {"chptell",2,(void *)pointch,0},
  112.   {"classno",1,(void *)classno,0},
  113.   {"classno2",1,(void *)classno2,0},
  114.   {"coeff",21,(void *)truecoeff,0},
  115.   {"compo",21,(void *)compo,0},
  116.   {"compose",2,(void *)compose,0},
  117.   {"comprealraw",2,(void *)comprealraw,0},
  118.   {"concat",2,(void *)concat,0},
  119.   {"conj",1,(void *)gconj,0},
  120.   {"content",1,(void *)content,0},
  121.   {"convol",2,(void *)convol,0},
  122.   {"cos",1,(void *)gcos,0},
  123.   {"cosh",1,(void *)gch,0},
  124.   {"cvtoi",13,(void *)gcvtoi,0},
  125.   {"cyclo",11,(void *)cyclo,0},
  126.   {"denom",1,(void *)denom,0},
  127.   {"deriv",14,(void *)deriv,0},
  128.   {"det",1,(void *)det,0},
  129.   {"det2",1,(void *)det2,0},
  130.   {"detr",1,(void *)detreel,0},
  131.   {"dilog",1,(void *)dilog,0},
  132.   {"disc",1,(void *)discsr,0},
  133.   {"discf",1,(void *)discf,0},
  134.   {"divisors",1,(void *)divisors,0},
  135.   {"divres",2,(void *)gdiventres,0},
  136.   {"divsum",22,(void *)divsomme,0},
  137.   {"eigen",1,(void *)eigen,0},
  138.   {"eint1",1,(void *)eint1,0},
  139.   {"erfc",1,(void *)gerfc,0},
  140.   {"eta",1,(void *)eta,0},
  141.   {"euler",0,(void *)mpeuler,0},
  142.   {"eval",1,(void *)geval,0},
  143.   {"exp",1,(void *)gexp,0},
  144.   {"extract",2,(void *)extract,0},
  145.   {"fact",11,(void *)mpfactr,0},
  146.   {"factfq",3,(void *)factmod9,0},
  147.   {"factmod",2,(void *)factmod,0},
  148.   {"factor",1,(void *)factor,0},
  149.   {"factoredbase",28,(void *)factoredbase,0},
  150.   {"factoreddiscf",2,(void *)factoreddiscf,0},
  151.   {"factoredpolred",2,(void *)factoredpolred,0},
  152.   {"factoredpolred2",2,(void *)factoredpolred2,0},
  153.   {"factornf",2,(void *)polfnf,0},
  154.   {"factorpadic",32,(void *)factorpadic,0},
  155.   {"factpol",21,(void *)factpol,0},
  156.   {"factpol2",21,(void *)factpol2,0},
  157.   {"fibo",11,(void *)fibo,0},
  158.   {"floor",1,(void *)gfloor,0},
  159.   {"for",83,(void *)forpari,0},
  160.   {"fordiv",84,(void *)fordiv,0},
  161.   {"forprime",83,(void *)forprime,0},
  162.   {"forstep",86,(void *)forstep,0},
  163.   {"frac",1,(void *)gfrac,0},
  164.   {"galois",1,(void *)galois,0},
  165.   {"galoisconj",1,(void *)galoisconj,0},
  166.   {"gamh",1,(void *)ggamd,0},
  167.   {"gamma",1,(void *)ggamma,0},
  168.   {"gauss",2,(void *)gauss,0},
  169.   {"gcd",2,(void *)ggcd,0},
  170.   {"globalred",1,(void *)globalreduction,0},
  171.   {"goto",61,0,0},
  172.   {"hclassno",1,(void *)classno3,0},
  173.   {"hell",2,(void *)ghell,0},
  174.   {"hell2",2,(void *)ghell2,0},
  175.   {"hell3",2,(void *)ghell3,0},
  176.   {"hermite",1,(void *)hnf,0},
  177.   {"hess",1,(void *)hess,0},
  178.   {"hilb",30,(void *) hil,0},
  179.   {"hilbert",11,(void *)hilb,0},
  180.   {"hilbp",20,(void *) hil,0},
  181.   {"hvector",22,(void *)vecteur,0},
  182.   {"hyperu",3,(void *)hyperu,0},
  183.   {"i",0,(void *)geni,0},
  184.   {"idmat",11,(void *)idmat,0},
  185.   {"if",80,0,0},
  186.   {"imag",1,(void *)gimag,0},
  187.   {"image",1,(void *)image,0},
  188.   {"image2",1,(void *)image2,0},
  189.   {"incgam",2,(void *)incgam,0},
  190.   {"incgam1",2,(void *)incgam1,0},
  191.   {"incgam2",2,(void *)incgam2,0},
  192.   {"incgam3",2,(void *)incgam3,0},
  193.   {"incgam4",3,(void *)incgam4,0},
  194.   {"indexrank",1,(void *)indexrank,0},
  195.   {"indsort",1,(void *)indexsort,0},
  196.   {"initalg",1,(void *)initalg,0},
  197.   {"initell",1,(void *)initell,0},
  198.   {"initell2",1,(void *)initell2,0},
  199.   {"integ",14,(void *)integ,0},
  200.   {"intersect",2,(void *)intersect,0},
  201.   {"intgen",37,(void *)rombint,0},
  202.   {"intinf",37,(void *)qromi,0},
  203.   {"intnum",37,(void *)qromb,0},
  204.   {"intopen",37,(void *)qromo,0},
  205.   {"inverseimage",2,(void *)inverseimage,0},
  206.   {"isfund",10,(void *)isfundamental,0},
  207.   {"isincl",2,(void *)nfincl,0},
  208.   {"isisom",2,(void *)nfiso,0},
  209.   {"isoncurve",20,(void *)oncurve,0},
  210.   {"isprime",10,(void *)isprime,0},
  211.   {"ispsp",10,(void *)ispsp,0},
  212.   {"isqrt",1,(void *)racine,0},
  213.   {"issqfree",10,(void *)issquarefree,0},
  214.   {"issquare",10,(void *)carreparfait,0},
  215.   {"jacobi",1,(void *)jacobi,0},
  216.   {"jbesselh",2,(void *)jbesselh,0},
  217.   {"jell",1,(void *)jell,0},
  218.   {"kbessel",2,(void *)kbessel,0},
  219.   {"kbessel2",2,(void *)kbessel2,0},
  220.   {"ker",1,(void *)ker,0},
  221.   {"keri",1,(void *)keri,0},
  222.   {"kerint",1,(void *)kerint,0},
  223.   {"kerint1",1,(void *)kerint1,0},
  224.   {"kerint2",1,(void *)kerint2,0},
  225.   {"kerr",1,(void *)kerreel,0},
  226.   {"kill",85,0,0},
  227.   {"kro",20,(void *)kronecker,0},
  228.   {"label",60,0,0},
  229.   {"laplace",1,(void *)laplace,0},
  230.   {"lcm",2,(void *)glcm,0},
  231.   {"legendre",11,(void *)legendre,0},
  232.   {"length",1,(void *)glength,0},
  233.   {"lex",20,(void *)lexcmp,0},
  234.   {"lexsort",1,(void *)lexsort,0},
  235.   {"lift",1,(void *)lift,0},
  236.   {"lindep",1,(void *)lindep,0},
  237.   {"lindep2",23,(void *)lindep2,0},
  238.   {"lll",1,(void *)lll,0},
  239.   {"lll1",1,(void *)lll1,0},
  240.   {"lllgram",1,(void *)lllgram,0},
  241.   {"lllgram1",1,(void *)lllgram1,0},
  242.   {"lllgramint",1,(void *)lllgramint,0},
  243.   {"lllgramkerim",1,(void *)lllgramkerim,0},
  244.   {"lllint",1,(void *)lllint,0},
  245.   {"lllkerim",1,(void *)lllkerim,0},
  246.   {"lllrat",1,(void *)lllrat,0},
  247.   {"ln",1,(void *)glog,0},
  248.   {"lngamma",1,(void *)glngamma,0},
  249.   {"localred",2,(void *)localreduction,0},
  250.   {"log",1,(void *)glog,0},
  251.   {"logagm",1,(void *)glogagm,0},
  252.   {"lseriesell",4,(void *)lseriesell,0},
  253.   {"mat",1,(void *)gtomat,0},
  254.   {"matell",2,(void *)matell,0},
  255.   {"matextract",3,(void *)matextract,0},
  256.   {"matinvr",1,(void *)invmatreel,0},
  257.   {"matsize",1,(void *)matsize,0},
  258.   {"matrix",49,(void *)matrice,0},
  259.   {"matrixqz",2,(void *)matrixqz,0},
  260.   {"matrixqz2",1,(void *)matrixqz2,0},
  261.   {"matrixqz3",1,(void *)matrixqz3,0},
  262.   {"max",2,(void *)gmax,0},
  263.   {"min",2,(void *)gmin,0},
  264.   {"minim",1,(void *)minim,0},
  265.   {"mod",25,(void *)gmodulcp,0},
  266.   {"modp",25,(void *)gmodulo,0},
  267.   {"modreverse",1,(void *)polymodrecip,0},
  268.   {"mu",10,(void *)mu,0},
  269.   {"newtonpoly",2,(void *)newtonpoly,0},
  270.   {"nextprime",1,(void *)bigprem,0},
  271.   {"norm",1,(void *)gnorm,0},
  272.   {"norml2",1,(void *)gnorml2,0},
  273.   {"nucomp",3,(void *)nucomp,0},
  274.   {"numdiv",1,(void *)numbdiv,0},
  275.   {"numer",1,(void *)numer,0},
  276.   {"nupow",2,(void *)nupow,0},
  277.   {"o",50,0,0},
  278.   {"omega",10,(void *)omega,0},
  279.   {"ordell",2,(void *)ordell,0},
  280.   {"order",1,(void *)order,0},
  281.   {"ordred",1,(void *)ordred,0},
  282.   {"pascal",11,(void *)pasc,0},
  283.   {"permutation",24,(void *)permute,0},
  284.   {"pf",2,(void *)primeform,0},
  285.   {"phi",1,(void *)phi,0},
  286.   {"pi",0,(void *)mppi,0},
  287.   {"plot",37,(void *)plot,0},
  288.   {"ploth",37,(void *)ploth,0},
  289.   {"ploth2",37,(void *)ploth2,0},
  290.   {"pnqn",1,(void *)pnqn,0},
  291.   {"pointell",2,(void *)pointell,0},
  292.   {"polint",31,(void *)polint,0},
  293.   {"polred",1,(void *)polred,0},
  294.   {"polred2",1,(void *)polred2,0},
  295.   {"polsym",21,(void *)polsym,0},
  296.   {"poly",14,(void *)gtopoly,0},
  297.   {"polylog",24,(void *)gpolylog,0},
  298.   {"polylogd",24,(void *)polylogd,0},
  299.   {"polylogdold",24,(void *)polylogdold,0},
  300.   {"polylogp",24,(void *)polylogp,0},
  301.   {"polyrev",14,(void *)gtopolyrev,0},
  302.   {"powell",3,(void *)powell,0},
  303.   {"powrealraw",23,(void *)powrealraw,0},
  304.   {"pprint",54,0,0},
  305.   {"pprint1",52,0,0},
  306.   {"prec",21,(void *)gprec,0},
  307.   {"prime",11,(void *)prime,0},
  308.   {"primes",11,(void *)primes,0},
  309.   {"primroot",1,(void *)gener,0},
  310.   {"print",53,0,0},
  311.   {"print1",51,0,0},
  312.   {"prod",48,(void *)produit,0},
  313.   {"prodeuler",37,(void *)prodeuler,0},
  314.   {"prodinf",27,(void *)prodinf,0},
  315.   {"prodinf1",27,(void *)prodinf1,0},
  316.   {"psi",1,(void *)gpsi,0},
  317.   {"qfi",3,(void *)qfi,0},
  318.   {"qfr",4,(void *)qfr,0},
  319.   {"quadgen",1,(void *)quadgen,0},   
  320.   {"quadpoly",1,(void *)quadpoly,0},   
  321.   {"random",0,(void *)genrand,0},
  322.   {"rank",10,(void *)rank,0},
  323.   {"read",56,0,0},
  324.   {"real",1,(void *)greal,0},
  325.   {"recip",1,(void *)polrecip,0},      
  326.   {"redcomp",1,(void *)redcomp,0},      
  327.   {"redreal",1,(void *)redreal,0},      
  328.   {"redrealnod",2,(void *)redrealnod,0},      
  329.   {"regula",1,(void *)regula,0}, 
  330.   {"reorder",1,(void *)reorder,0}, 
  331.   {"resultant",2,(void *)subres,0},    
  332.   {"resultant2",2,(void *)resultant2,0},    
  333.   {"reverse",1,(void *)recip,0}, 
  334.   {"rhoreal",1,(void *)rhoreal,0},      
  335.   {"rhorealnod",2,(void *)rhorealnod,0},      
  336.   {"rndtoi",13,(void *)grndtoi,0},
  337.   {"rootmod",2,(void *)rootmod,0},
  338.   {"rootmod2",2,(void *)rootmod2,0},
  339.   {"rootpadic",32,(void *)rootpadic,0},
  340.   {"roots",1,(void *)roots,0},
  341.   {"rootslong",1,(void *)rootslong,0},
  342.   {"rootsof1",10,(void *)rootsof1,0},
  343.   {"round",1,(void *)ground,0},
  344.   {"rounderror",10,(void *)rounderror,0},
  345.   {"series",14,(void *)gtoser,0},
  346.   {"setprecision",15,(void *)setprecr,0},
  347.   {"setserieslength",15,(void *)setserieslength,0},
  348.   {"shift",21,(void *)gshift,0},
  349.   {"shiftmul",21,(void *)gmul2n,0},
  350.   {"sigma",1,(void *)sumdiv,0},
  351.   {"sigmak",24,(void *)sumdivk,0},
  352.   {"sign",10,(void *)gsigne,0},
  353.   {"signat",1,(void *)signat,0},
  354.   {"simplify",1,(void *)simplify,0},
  355.   {"sin",1,(void *)gsin,0},
  356.   {"sinh",1,(void *)gsh,0},
  357.   {"size",10,(void *)gsize,0},
  358.   {"smallbase",13,(void *)smallbase,0},
  359.   {"smalldiscf",1,(void *)smalldiscf,0},
  360.   {"smallfact",1,(void *)smallfact,0},
  361.   {"smallinitell",1,(void *)smallinitell,0},
  362.   {"smallpolred",1,(void *)smallpolred,0},
  363.   {"smallpolred2",1,(void *)smallpolred2,0},
  364.   {"smith",1,(void *)smith,0},
  365.   {"smith2",1,(void *)smith2,0},
  366.   {"solve",37,(void *)zbrent,0},
  367.   {"sort",1,(void *)sort,0},
  368.   {"sqr",1,(void *)gsqr,0},
  369.   {"sqred",1,(void *)sqred,0},
  370.   {"sqrt",1,(void *)gsqrt,0},
  371.   {"srgcd",2,(void *)srgcd,0},
  372.   {"sturm",10,(void *)sturm,0},
  373.   {"sturmpart",30,(void *)sturmpart,0},
  374.   {"subell",3,(void *)subell,0},
  375.   {"subst",26,(void *)gsubst,0},
  376.   {"sum",48,(void *)somme,0},
  377.   {"sumalt",27,(void *)sumalt,0},
  378.   {"suminf",27,(void *)suminf,0},
  379.   {"sumpos",27,(void *)sumpos,0},
  380.   {"supplement",1,(void *)suppl,0},
  381.   {"tan",1,(void *)gtan,0},
  382.   {"tanh",1,(void *)gth,0},
  383.   {"taylor",12,(void *)tayl,0},
  384.   {"tchebi",11,(void *)tchebi,0},
  385.   {"tchirnhausen",1,(void *)tchirnhausen,0},
  386.   {"teich",1,(void *)teich,0},
  387.   {"texprint",55,0,0},
  388.   {"theta",2,(void *)theta,0},
  389.   {"thetanullk",21,(void *)thetanullk,0},
  390.   {"trace",1,(void *)trace,0},
  391.   {"trans",1,(void *)gtrans,0},
  392.   {"trunc",1,(void *)gtrunc,0},
  393.   {"type",1,(void *)gtype,0},
  394.   {"unit",1,(void *)fundunit,0},
  395.   {"until",82,0,0},
  396.   {"valuation",20,(void *)ggval,0},
  397.   {"vec",1,(void *)gtovec,0},
  398.   {"vecsort",21,(void *)vecsort,0},
  399.   {"vector",22,(void *)vecteur,0},
  400.   {"vvector",22,(void *)vvecteur,0},
  401.   {"wf",1,(void *)wf,0},
  402.   {"wf2",1,(void *)wf2,0},
  403.   {"while",81,0,0},
  404.   {"zell",2,(void *)zell,0},
  405.   {"zeta",1,(void *)gzeta,0},
  406.   {"zzzz",1,(void *)kerint2,0}
  407. };
  408.  
  409. long    NUMFUNC=sizeof(fonctions)/sizeof(entree);
  410.  
  411. static void matcherr(c)
  412.      char c;
  413. {
  414.   static char reste[100];
  415.   char *p;
  416.   long i;
  417.   
  418.   for(analyseurs--, p=reste, *p++=c, i=0; i<97; i++) *p++ = *analyseurs++;
  419.   *p = 0;err(matcher1,reste);
  420. }
  421.  
  422. #define match(c)  if(*analyseurs++ != c) matcherr(c)
  423.  
  424. GEN seq()
  425.      
  426. {
  427.   GEN res=gnil;
  428.   for(;;)
  429.     {
  430.       while(separe(*analyseurs)) analyseurs++;
  431.       if ((!*analyseurs) || (*analyseurs == ')') || (*analyseurs == ',')) return res;
  432.       res = expr();
  433.       if(!separe(*analyseurs)) return res;
  434.     }
  435. }
  436.  
  437. GEN expr()
  438. {
  439.   GEN (*func[4]) (),aux,e,e1,e2,e3;
  440.   long niveau;
  441.   
  442.   for(niveau=0;niveau<4;niveau++) func[niveau]=NULL;
  443.   e1=e2=e3=(GEN)0;
  444.   niveau=3;
  445.   for(;;)
  446.     switch(niveau)
  447.       {
  448.       case 3: aux=facteur();
  449.         if(func[3]) {analyseurtetpil=avma;e3=func[3](e3,aux);}
  450.         else e3=aux;
  451.         switch(*analyseurs)
  452.       {
  453.           case '*': analyseurs++;func[3]=gmul;break;
  454.           case '/': analyseurs++;func[3]=gdiv;break;
  455.           case '\\': analyseurs++;func[3]=gdivent;break;
  456.           case '%': analyseurs++;func[3]=gmod;break;
  457.           default: niveau--;func[3]=NULL;
  458.       }
  459.         break;
  460.       case 2: 
  461.         if(!e3) {niveau++;break;}
  462.         if(func[2]) {analyseurtetpil=avma;e2=func[2](e2,e3);}
  463.         else e2=e3;
  464.         e3=(GEN)0;
  465.         switch(*analyseurs)
  466.       {
  467.           case '+': analyseurs++;func[2]=gadd;niveau++;break;
  468.           case '-': analyseurs++;func[2]=gsub;niveau++;break;
  469.           default: niveau--;func[2]=NULL;
  470.       }
  471.         break;
  472.       case 1: 
  473.         if(!e2) {niveau++;break;}
  474.         if(func[1]) {analyseurtetpil=avma;e1=func[1](e1,e2);}
  475.         else e1=e2;
  476.         e2=(GEN)0;
  477.         switch(*analyseurs)
  478.       {
  479.           case '<': analyseurs++;
  480.             switch(*analyseurs)
  481.           {
  482.               case '=': analyseurs++;func[1]=gle;break;
  483.               case '>': analyseurs++;func[1]=gne;break;
  484.         default : func[1]=glt;
  485.           }
  486.             niveau++;break;
  487.           case '>': analyseurs++;
  488.             if((*analyseurs)=='=') {analyseurs++;func[1]=gge;}
  489.             else func[1]=ggt;
  490.             niveau++;break;
  491.           case '=': 
  492.             if((analyseurs[1])=='=') {analyseurs+=2;func[1]=geq;niveau++;}
  493.             break;
  494.           case '!': 
  495.             if((analyseurs[1])=='=') {analyseurs+=2;func[1]=gne;niveau++;}
  496.             break;
  497.           default: niveau--;func[1]=NULL;
  498.       }
  499.         break;
  500.       case 0: 
  501.         if(!e1) {niveau++;break;}
  502.         if(func[0]) {analyseurtetpil=avma;e=func[0](e,e1);}
  503.         else e=e1;
  504.         e1=(GEN)0;
  505.         switch(*analyseurs)
  506.       {
  507.           case '&': analyseurs++;if(*analyseurs=='&') analyseurs++;func[0]=gand;niveau++;break;
  508.           case '|': analyseurs++;if(*analyseurs=='|') analyseurs++;func[0]=gor;niveau++;break;
  509.           default: return e;
  510.       }
  511.       }
  512. }
  513.  
  514. GEN facteur()
  515. {
  516.   GEN tru,p1,arg,arg1;
  517.   long tx,c,e,av2,flcol,flrow;
  518.   long plus = (*analyseurs =='+')||(*analyseurs =='-')?(*analyseurs++=='+'):1;
  519.   tru=truc();
  520.   for (;;) switch(*analyseurs)
  521.     {
  522.     case '^': analyseurs++;p1=facteur();analyseurtetpil=avma; tru=gpui(tru,p1,prec);break;
  523.     case '~': analyseurs++;analyseurtetpil=avma;tru=gtrans(tru);break;
  524.     case '_': analyseurs++;analyseurtetpil=avma;tru=gconj(tru);break;
  525.     case '\'': analyseurs++;analyseurtetpil=avma;tru=deriv(tru,gvar9(tru));break;
  526.     case '[': 
  527.       tx=typ(p1=tru);
  528.       if((tx<17)||(tx>19)) err(caracer1,analyseurs);
  529.       analyseurs++;av2=avma;flcol=flrow=0;
  530.       if(tx<19)
  531.     {
  532.       arg=expr();if(typ(arg)!=1) err(caseer);
  533.       c=itos(arg);if((c<1)||(c>=lg(p1))) err(arrayer1);
  534.     }
  535.       else
  536.     {
  537.       if(lg(p1)==1) err(arrayer1);
  538.       if(*analyseurs==',')
  539.         {
  540.           analyseurs++;arg=expr();if(typ(arg)!=1) err(caseer);
  541.           c=itos(arg);if((c<1)||(c>=lg(p1))) err(arrayer1);
  542.           flcol=1;
  543.         }
  544.       else
  545.         {
  546.           arg=expr();if(typ(arg)!=1) err(caseer);
  547.           e=itos(arg);if((e<1)||(e>=lg(p1[1]))) err(arrayer1);
  548.           match(',');
  549.           if(*analyseurs==']') flrow=1;
  550.           else
  551.         {
  552.           arg1=expr();if(typ(arg1)!=1) err(caseer);
  553.           c=itos(arg1);
  554.           if((c<1)||(c>=lg(p1))) err(arrayer1);
  555.         }
  556.         }
  557.     }
  558.       match(']'); analyseurtetpil=avma=av2;
  559.       if((tx<19)||flcol) tru=gcopy(p1[c]);
  560.       else
  561.     {
  562.       if(flrow)
  563.         {
  564.           tru=cgetg(lg(p1),17);
  565.           for(c=1;c<lg(p1);c++) tru[c]=lcopy(((GEN)p1[c])[e]);
  566.         }
  567.       else tru = gcopy(((GEN)p1[c])[e]);
  568.     }
  569.       break;
  570.     case '!': analyseurs++;if((*analyseurs)!='=') {analyseurtetpil=avma;tru=mpfact(itos(tru));break;} else analyseurs--;
  571.     default: if(plus) return tru; else {analyseurtetpil=avma;return gneg(tru);}
  572.     }
  573. }
  574.  
  575. GEN truc()
  576. {
  577.   long i,n=0,j,p=0,m=1;
  578.   GEN *table,p1;
  579.   
  580.   if (isalpha(*analyseurs)) return identifier();
  581.   if (isdigit(*analyseurs) || (*analyseurs=='.')) return constante();
  582.   switch(*analyseurs++)
  583.     {
  584.     case '(': p1=expr();match(')');return p1;
  585.     case '[':
  586.       table = (GEN *)newbloc(paribuffsize>>1);
  587.       if (*analyseurs!=']') 
  588.     {do table[++n]=expr();while (*analyseurs++==',');analyseurs--;}
  589.       switch (*analyseurs++)
  590.     {
  591.         case ']': analyseurtetpil=avma;p1=cgetg(n+1,17);
  592.           for (i=1;i<=n;i++) p1[i]=lcopy(table[i]);
  593.           break;
  594.         case ';': m=n;do table[++n]=expr();while (*analyseurs++!=']');
  595.           if (n % m) err(recter1);
  596.           p=n/m;analyseurtetpil=avma;p1=cgetg(m+1,19);
  597.           for (i=1;i<=m;i++) p1[i]=(long)cgetg(p+1,18);
  598.           for (j=1;j<=m;j++)
  599.             for(i=1;i<=p;i++)
  600.               ((GEN)p1[j])[i]=lcopy(table[(i-1)*m+j]);
  601.           break;
  602.         default: err(vectmater1);
  603.     }
  604.       killbloc((GEN)table);
  605.       return p1;
  606.     case '%':
  607.       p=0;while((*analyseurs)=='`') {analyseurs++;p++;}
  608.       if(p>tglobal) err(referer1);
  609.       if(p) return g[tglobal-p];
  610.       while (isdigit(*analyseurs)) p = 10*p + *analyseurs++ - '0';
  611.       if(p>tglobal) err(referer2);
  612.       return g[p];
  613.     }
  614.   err(caracer1,analyseurs-1);
  615. }
  616.  
  617. GEN identifier()
  618. {
  619.   long c,e,va,m,nparam,i,av,av2,tx,flrow,flcol;
  620.   static long yatileugoto;
  621.   GEN arg,arg1,arg2,arg3,res=gnil,(*f)(),p1;
  622.   char *ch1, *ch2, *readbuffer;
  623.   entree *ep, *ep1, **p;
  624.   
  625.   ep = findentry();
  626.   if (ep->valence < 100) /* fonctions predefinies */
  627.     {
  628.       f = (GEN (*)())ep->value;
  629.       if (!ep->valence && (*analyseurs != '(')) return (*f)(prec);
  630.       match('(');
  631.       switch(ep->valence)
  632.     {
  633.     case 0: res=(*f)(prec);break;
  634.     case 1: arg=expr();analyseurtetpil=avma;
  635.       res=(*f)(arg,prec);break;
  636.     case 2: arg=expr();match(',');arg1=expr();
  637.       analyseurtetpil=avma;res=(*f)(arg,arg1,prec);break;
  638.     case 3: arg=expr();match(',');arg1=expr();
  639.       match(',');arg2=expr();analyseurtetpil=avma;
  640.       res=(*f)(arg,arg1,arg2,prec);break;
  641.     case 4: arg=expr();match(',');arg1=expr();
  642.       match(',');arg2=expr();match(',');arg3=expr();analyseurtetpil=avma;
  643.       res=(*f)(arg,arg1,arg2,arg3,prec);break;
  644.     case 10: p1=(*f)(expr());analyseurtetpil=avma;
  645.       res=stoi(p1);break;
  646.     case 11: arg=expr();if(typ(arg)!=1) err(caseer);
  647.       analyseurtetpil=avma;res=(*f)(itos(arg),prec);break;
  648.     case 12: arg=expr();match(',');arg1=expr();va=numvar(arg1);
  649.       analyseurtetpil=avma;res=(*f)(arg,va,precdl);break;
  650.     case 13: arg=expr();analyseurtetpil=avma;
  651.       res=(*f)(arg,&e);break;
  652.     case 14: arg=expr();match(',');arg1=expr();va=numvar(arg1);
  653.       analyseurtetpil=avma;res=(*f)(arg,va);break;
  654.     case 15: arg=expr();if(typ(arg)!=1) err(caseer);
  655.       analyseurtetpil=avma;res=stoi((*f)(itos(arg)));break;
  656.     case 20: arg=expr();match(',');
  657.       p1=(*f)(arg,expr());analyseurtetpil=avma;
  658.       res=stoi(p1);break;
  659.     case 21: arg=expr();match(',');arg1=expr();if(typ(arg1)!=1) err(caseer);
  660.       analyseurtetpil=avma;res=(*f)(arg,itos(arg1));break;
  661.     case 22: arg=expr();match(',');
  662.       if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  663.       ep = findentry();if (ep->valence!=200) err(varer1,analyseurs);match(',');
  664.       analyseurtetpil=avma;
  665.       res=(*f)(ep,arg,analyseurs); skipexpr(); break;
  666.     case 23: arg=expr();match(',');arg1=expr();if(typ(arg1)!=1) err(caseer);
  667.       analyseurtetpil=avma;res=(*f)(arg,itos(arg1),prec);break;
  668.     case 24: arg=expr();if(typ(arg)!=1) err(caseer);
  669.       match(',');arg1=expr();analyseurtetpil=avma;
  670.       res=(*f)(itos(arg),arg1,prec);break;
  671.     case 25: arg=expr();match(',');arg1=expr();analyseurtetpil=avma;
  672.       res=(*f)(arg,arg1);break;
  673.     case 26: arg=expr();match(',');arg1=expr();
  674.       va=numvar(arg1);match(',');arg2=expr();
  675.       analyseurtetpil=avma;res=(*f)(arg,va,arg2);break;
  676.     case 27: if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  677.       ep = findentry();match('='); if (ep->valence!=200) err(varer1,analyseurs);
  678.       arg=expr(); match(','); analyseurtetpil=avma;
  679.       res=(*f)(ep,arg,analyseurs,prec); skipexpr(); break;
  680.     case 28: arg=expr();match(',');arg1=expr();
  681.       analyseurtetpil=avma;res=(*f)(arg,arg1,&e);break;
  682.     case 29: arg=expr();match(',');arg1=expr();if(typ(arg1)!=1) err(caseer);
  683.       p1=(*f)(arg,itos(arg1));analyseurtetpil=avma;
  684.       res=stoi(p1);break;
  685.     case 30: arg=expr();match(',');arg1=expr();match(',');
  686.       p1=(*f)(arg,arg1,expr());analyseurtetpil=avma;
  687.       res=stoi(p1);break;
  688.     case 31: arg=expr();match(',');arg1=expr();match(',');
  689.       analyseurtetpil=avma;res=(*f)(arg,arg1,expr(),&arg2);cgiv(arg2);
  690.       break;
  691.     case 32: arg=expr();match(',');arg1=expr();match(',');arg2=expr();
  692.       if(typ(arg2)!=1) err(caseer);
  693.       analyseurtetpil=avma;res=(*f)(arg,arg1,itos(arg2));break;
  694.     case 33: arg=expr();match(',');arg1=expr();match(',');arg2=expr();
  695.       if((typ(arg2)!=1)||(typ(arg1)!=1)) err(caseer);
  696.       analyseurtetpil=avma;res=(*f)(arg,itos(arg1),itos(arg2),prec);break;
  697.     case 37: if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  698.       ep = findentry();match('='); if (ep->valence!=200) err(varer1,analyseurs);
  699.       arg=expr(); match(','); arg1=expr(); match(','); 
  700.       analyseurtetpil=avma;
  701.       res=(*f)(ep,arg,arg1,analyseurs,prec); skipexpr(); break;
  702.     case 48: arg=expr(); match(',');
  703.       if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  704.       ep = findentry();match('='); if (ep->valence!=200) err(varer1,analyseurs);
  705.       arg1=expr(); match(','); arg2=expr(); match(',');
  706.       analyseurtetpil=avma;
  707.       res=(*f)(ep,arg,arg1,arg2,analyseurs,prec); skipexpr(); break;
  708.     case 49: arg=expr();match(','); arg1=expr(); match(',');
  709.       if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  710.       ep = findentry();if (ep->valence!=200) err(varer1,analyseurs);match(',');
  711.       if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  712.       ep1 = findentry();if (ep1->valence!=200) err(varer1,analyseurs);match(',');
  713.       analyseurtetpil=avma;
  714.       res=(*f)(ep,ep1,arg,arg1,analyseurs); skipexpr(); break;
  715.     case 50: p1=truc();
  716.       if (*analyseurs++=='^') 
  717.         {
  718.           arg=facteur();if(typ(arg)!=1) err(caseer);
  719.           e=itos(arg);
  720.         }
  721.       else {e = 1; analyseurs--;}
  722.       analyseurtetpil=avma; res = ggrando(p1,e); break;
  723.     case 51: case 52: case 53: case 54: case 55:
  724.       if (*analyseurs != ')') for(;;)
  725.         {
  726.           if (*analyseurs == '"')
  727.         {
  728.           analyseurs++;
  729.           while ((*analyseurs)&&(*analyseurs!='"')) pariputc(*analyseurs++);
  730.           match('"');
  731.         }
  732.           else
  733.         {
  734.           analyseurtetpil=avma;
  735.           if (ep->valence == 55) f = (GEN (*)()) texe;
  736.           else if(ep->valence&1) f = (GEN (*)()) brute;else f = (GEN (*)()) sor;
  737.           (*f)(res=expr(),glbfmt[0],glbfmt[2],glbfmt[1]);
  738.         }
  739.           if (*analyseurs == ')') break;
  740.           match(',');
  741.         }
  742.       if (ep->valence>52) pariputc('\n'); 
  743.       fflush(outfile); if (logfile) fflush(logfile); break;
  744.     case 56: 
  745.       readbuffer = (char *)newbloc(paribuffsize>>2);
  746.       while(!fgets(readbuffer, paribuffsize, infile)) switchin(NULL);
  747.       if (pariecho) pariputs(readbuffer);
  748.       else if (logfile) fputs(readbuffer, logfile);
  749.       res=lisseq(readbuffer);killbloc((GEN)readbuffer);break;
  750.     case 60: arg=expr();if(typ(arg)!=1) err(caseer);
  751.       m=itos(arg);if((m>=100)||(m<0)) err(labeler);
  752.       labellist[m]=analyseurs;break;
  753.     case 61: arg=expr();if(typ(arg)!=1) err(caseer);
  754.       m=itos(arg);if((m>=100)||(m<0)||(!labellist[m])) err(labeler);
  755.       analyseurs=labellist[m];yatileugoto=1;break;
  756.     case 80: av = avma; c=gcmp0(expr()); analyseurtetpil = avma = av; match(',');
  757.       if (c) {skipseq();match(',');res = seq();}
  758.       else 
  759.         {
  760.           yatileugoto=0;res = seq();
  761.           if(!yatileugoto) {match(',');skipseq();}
  762.         }
  763.       break;
  764.     case 81: analyseurtetpil = av = avma; ch1 = analyseurs;
  765.       while (!gcmp0(expr()))
  766.         {
  767.           analyseurtetpil = avma = av; match(',');
  768.           yatileugoto=0;seq();
  769.           if(!yatileugoto) analyseurs = ch1;else break;
  770.         }
  771.       if(!yatileugoto) {match(','); skipseq();}
  772.       break;
  773.     case 82: av = avma; ch1 = analyseurs;
  774.       skipexpr();
  775.       do 
  776.         {
  777.           analyseurtetpil = avma = av; match(','); 
  778.           yatileugoto=0;seq();
  779.           if(!yatileugoto) analyseurs = ch1;else break;
  780.         }
  781.       while (gcmp0(expr()));
  782.       if(!yatileugoto) {match(','); skipseq();}
  783.       break;
  784.     case 83: if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  785.       ep = findentry();match('='); if (ep->valence!=200) err(varer1,analyseurs);
  786.       arg=expr(); match(','); arg1=expr(); match(','); 
  787.       analyseurtetpil=avma;
  788.       res=(*f)(ep,arg,arg1,analyseurs); skipseq(); break;
  789.     case 84: arg=expr();match(',');
  790.       if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  791.       ep = findentry();if (ep->valence!=200) err(varer1,analyseurs);match(',');
  792.       analyseurtetpil=avma;
  793.       res=(*f)(ep,arg,analyseurs); skipseq(); break;
  794.     case 85: if(!isalpha(*analyseurs)) err(killer1);
  795.       ep = findentry(); if (ep->valence<100) err(killer1);
  796.       killvalue(ep);
  797.       if (ep->valence == 200) res = (GEN)ep->value;
  798.       else
  799.         {
  800.           for(i = 0; i<TBLSZ; i++)
  801.         if (hashtable[i] == ep) {hashtable[i] = ep->next; free(ep); break;}
  802.         else
  803.           for(ep1 = hashtable[i]; ep1; ep1 = ep1->next)
  804.             if (ep1->next == ep) {ep1->next = ep->next; free(ep); break;}
  805.         }
  806.       break;
  807.     case 86: if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  808.       ep = findentry();match('='); if (ep->valence!=200) err(varer1,analyseurs);
  809.       arg=expr();match(',');arg1=expr();match(',');arg2=expr();match(',');
  810.       analyseurtetpil=avma;
  811.       res=(*f)(ep,arg,arg1,arg2,analyseurs); skipseq(); break;
  812.       
  813.     default: err(valencer1);
  814.     }
  815.       match(')');return res;
  816.     }
  817.   switch (ep->valence)
  818.     {
  819.     case 200: /* variables */
  820.       if((*analyseurs)=='[')
  821.     {
  822.       tx=typ(p1=(GEN)ep->value);
  823.       if((tx<17)||(tx>19)) err(caracer1,analyseurs);
  824.       analyseurs++;av2=avma;flcol=flrow=0;
  825.       if(tx<19)
  826.         {
  827.           arg=expr();if(typ(arg)!=1) err(caseer);
  828.           c=itos(arg);if((c<1)||(c>=lg(p1))) err(arrayer1);
  829.         }
  830.       else
  831.         {
  832.           if(lg(p1)==1) err(arrayer1);
  833.           if(*analyseurs==',')
  834.         {
  835.           analyseurs++;arg=expr();if(typ(arg)!=1) err(caseer);
  836.           c=itos(arg);if((c<1)||(c>=lg(p1))) err(arrayer1);
  837.           flcol=1;
  838.         }
  839.           else
  840.         {
  841.           arg=expr();if(typ(arg)!=1) err(caseer);
  842.           e=itos(arg);if((e<1)||(e>=lg(p1[1]))) err(arrayer1);
  843.           match(',');
  844.           if(*analyseurs==']') flrow=1;
  845.           else
  846.             {
  847.               arg1=expr();if(typ(arg1)!=1) err(caseer);
  848.               c=itos(arg1);
  849.               if((c<1)||(c>=lg(p1))) err(arrayer1);
  850.             }
  851.         }
  852.         }
  853.       match(']'); avma=av2;
  854.       if(((*analyseurs)=='=')&&(*(analyseurs+1)!='=')) 
  855.         {
  856.           analyseurs++;res=expr();
  857.           if((tx==19)&&(!flcol))
  858.         {
  859.           if(flrow)
  860.             {
  861.               if((typ(res)!=17)||(lg(res)!=lg(p1))) err(caseer2);
  862.               for(c=1;c<lg(p1);c++) ((GEN)p1[c])[e]=(long)res[c];
  863. /* maybe lcopy(res[c]) instead ? */
  864.             }
  865.           else ((GEN)p1[c])[e]=(long)res;
  866.         }
  867.           else 
  868.         {
  869.           if(flcol)
  870.             {
  871.               if((typ(res)!=18)||(lg(res)!=lg(p1[1]))) err(caseer2);
  872.             }
  873.           p1[c]=(long)res;
  874.         }
  875.           changevalue(ep, p1);p1=(GEN)ep->value;
  876.         }
  877.       analyseurtetpil=avma;
  878.       if((tx<19)||flcol) return (GEN)p1[c];
  879.       else
  880.         {
  881.           if(flrow) 
  882.         {
  883.           res=cgetg(lg(p1),17);
  884.           for(c=1;c<lg(p1);c++) res[c]=((GEN)p1[c])[e];
  885. /* maybe lcopy() instead */
  886.           return res;
  887.         }
  888.           else return (GEN)((GEN)p1[c])[e];
  889.         }
  890.     }
  891.       if(((*analyseurs)=='=')&&(*(analyseurs+1)!='=')) 
  892.     {
  893.       analyseurs++;changevalue(ep, expr()); 
  894.     }
  895.       analyseurtetpil=avma;return (GEN)ep->value;
  896.       
  897.     case 100: /* fonctions utilisateur */
  898.       ch1 = analyseurs;
  899.       match('(');
  900.       p = (entree **)ep->value;
  901.       nparam = (long)*p++;
  902.       arg1 = arg = cgetg(nparam+1, 17);
  903.       for(i = 0; (i < nparam) && (*analyseurs != ')'); i++)
  904.     {
  905.       if (i) match(',');
  906.       *++arg = (long)expr();
  907.     }
  908.       if ((*analyseurs==')') && ((analyseurs[1] != '=') || (analyseurs[2] == '=')))
  909.     {
  910.       analyseurs++;
  911.       while(i++ < nparam) *++arg = zero;
  912.       analyseurtetpil = avma;
  913.       for(i=0; i<nparam; i++) newvalue(*p++, *++arg1);
  914.       res = lisseq((char *)p);
  915.           res = forcecopy(res);
  916.       for(i = 0; i < nparam; i++) 
  917.             killvalue(*--p);
  918.       return res;
  919.     }
  920.       while (*analyseurs == ',') {analyseurs++; skipexpr();}
  921.       match(')');
  922.       if ((*analyseurs != '=') || (analyseurs[1] == '=')) err(nparamer1);
  923.       analyseurs = ch1;
  924.       killbloc(ep->value);
  925.       
  926.     case 101: /* nouvelle fonction */
  927.       
  928.       match('(');
  929.       ch1 = analyseurs;
  930.       for(nparam = 0; *analyseurs != ')'; nparam++)
  931.     {
  932.       if (nparam) match(',');
  933.       if (!isalpha(*analyseurs)) err(paramer1);
  934.       if (skipentry()->valence != 200) err(paramer1);
  935.     }
  936.       match(')'); match('='); ch2 = analyseurs; skipseq(); 
  937.       p = (entree **)newbloc(nparam + (analyseurs - ch2) / 4 + 2);
  938.       p[-1] = (entree *)ep->value;
  939.       ep->value = (void *)p;
  940.       *p++ = (entree *)nparam;
  941.       ch2 = analyseurs; analyseurs = ch1;
  942.       for(i = 0; i < nparam; i++)
  943.     {
  944.       if (i) match(',');
  945.       *p++ = ep1 = findentry();
  946.       if (ep1->valence != 200) err(paramer1);
  947.     }      
  948.       match(')'); match('=');
  949.       strncpy((char *)p, analyseurs, ch2 - analyseurs);
  950.       *((char *)p + (ch2 - analyseurs)) = 0;
  951.       ep->valence = 100;
  952.       analyseurs = ch2;
  953.       return gnil;
  954.       
  955.     default: err(valencer1);
  956.     }
  957. }
  958.  
  959. static long  word(nb)
  960.      long *nb;
  961. {
  962.   int m=0;
  963.   for(*nb = 0; (*nb < 9) && isdigit(*analyseurs); (*nb)++)
  964.     m = 10 * m + *analyseurs++-'0';
  965.    return m;
  966. }
  967.  
  968. GEN constante()
  969. {
  970.   static long pw10[] = {1, 10, 100, 1000, 10000, 100000,
  971.                           1000000, 10000000, 100000000, 1000000000};
  972.   long l,m=0,n=0,plus=1,nb, av = avma, limite=(avma + bot)/2;
  973.   GEN z,y;
  974.   
  975.   analyseurtetpil=avma;
  976.   y = stoi(word(&nb));
  977.   while (isdigit(*analyseurs))
  978.     {
  979.       m = word(&nb); y = mulsi(pw10[nb], y);
  980.       analyseurtetpil = avma;
  981.       y = addsi(m, y);
  982.       if (avma < limite)
  983.         {
  984.           y = gerepile(av, analyseurtetpil, y);
  985.           analyseurtetpil = av;
  986.         }
  987.     }
  988.   if ((*analyseurs!='.')&&(*analyseurs!='e')&&(*analyseurs!='E')) return y;
  989.   if (*analyseurs=='.') 
  990.     {
  991.       analyseurs++;
  992.       while (isdigit(*analyseurs))
  993.         {
  994.           m = word(&nb); y = mulsi(pw10[nb], y);
  995.           analyseurtetpil = avma;
  996.           y = addsi(m, y);
  997.           if (avma < limite)
  998.             {
  999.               y = gerepile(av, analyseurtetpil, y);
  1000.               analyseurtetpil = av;
  1001.             }
  1002.           n -= nb;
  1003.         }
  1004.     }
  1005.   l=lgef(y);if(l<prec) l=prec;
  1006.   analyseurtetpil=avma;
  1007.   z=cgetr(l);affir(y,z);
  1008.   if ((*analyseurs=='e') || (*analyseurs=='E'))
  1009.     {
  1010.       analyseurs++;
  1011.       if (((*analyseurs)=='+') || ((*analyseurs)=='-')) plus=(*analyseurs++=='+');
  1012.       m = word(&nb);
  1013.       if(isdigit(*analyseurs)) err(expter1);
  1014.       if (plus) n += m;else n -= m;
  1015.     }
  1016.   if (n)
  1017.     {
  1018.       affsr(10, y = cgetr(l));
  1019.       y = gpuigs(y, abs(n));
  1020.       analyseurtetpil=avma;
  1021.       z = n > 0 ?  mulrr(z, y) : divrr(z, y);
  1022.     }
  1023.   return z;
  1024. }
  1025.  
  1026. entree *findentry()
  1027. {
  1028.   char *olds = analyseurs, *u, *v;
  1029.   long sv, n;
  1030.   GEN p1;
  1031.   entree *ep;
  1032.   
  1033.   for (n = 0; isalnum(*analyseurs); analyseurs++) n = n << 1 ^ *analyseurs;
  1034.   if (n < 0) n = -n; n %= TBLSZ;
  1035.   for(ep = hashtable[n]; ep; ep = ep->next)
  1036.     {
  1037.       for(u = ep->name, v = olds; (*u) && *u == *v; u++, v++);
  1038.       if (!*u && (v == analyseurs)) return ep;
  1039.     }
  1040.   sv = (*analyseurs == '(') ? 0 : 28;
  1041.   ep = (entree *)malloc(sizeof(entree) + sv + analyseurs - olds + 1);
  1042.   ep->name = (char *)ep + sizeof(entree) + sv;
  1043.   for (u = ep->name, v = olds; v < analyseurs;) *u++ = *v++; *u = 0;
  1044.   ep->value = (void *)((char *)ep + sizeof(entree));
  1045.   ep->next = hashtable[n];
  1046.   hashtable[n] = ep;
  1047.   p1 = (GEN)ep->value;
  1048.   if (*analyseurs == '(') ep->valence = 101;
  1049.   else
  1050.     {
  1051.       if (nvar == MAXVAR) err(trucer1);
  1052.       ep->valence = 200;
  1053.       p1[0] = 0x0a010004; p1[1] = 0x01000004 + (nvar << 16); p1[2] = zero; p1[3] = un;
  1054.       polx[nvar] = p1;
  1055.       polvar[nvar+1] = (long)p1;
  1056.       p1 += 4;
  1057.       p1[0] = 0x0a010003; p1[1] = 0x01000003 + (nvar << 16); p1[2] = un;
  1058.       polun[nvar] = p1;
  1059.       varentries[nvar++] = ep;
  1060.       setlg(polvar, nvar+1);
  1061.     }
  1062.   return ep;
  1063. }
  1064.  
  1065. numvar(x)
  1066.      GEN x;
  1067. {
  1068.   if(typ(x)!=10) err(numvarer);
  1069.   if(lgef(x)!=4) err(numvarer);
  1070.   if((!gcmp0(x[2])) || (!gcmp1(x[3]))) err(numvarer);
  1071.   return varn(x);
  1072. }
  1073.  
  1074.  
  1075. void skipseq()
  1076. {
  1077.   for(;;)
  1078.     {
  1079.       while(separe(*analyseurs)) analyseurs++;
  1080.       if ((!*analyseurs) || (*analyseurs == ')') || (*analyseurs == ',')) return;
  1081.       skipexpr();
  1082.       if(!separe(*analyseurs)) return;
  1083.     }
  1084. }
  1085.  
  1086. void skipexpr()
  1087. {
  1088.   long niveau=3,e1,e2,e3;
  1089.   
  1090.   e1=e2=e3=0;
  1091.   for(;;)
  1092.     switch(niveau)
  1093.       {
  1094.       case 3: e3=1;skipfacteur();
  1095.         switch(*analyseurs)
  1096.       {
  1097.           case '*': 
  1098.           case '/': 
  1099.           case '\\':
  1100.           case '%': analyseurs++;break;
  1101.           default: niveau--;
  1102.       }
  1103.         break;
  1104.       case 2:
  1105.         if(!e3) {niveau++;break;}
  1106.         e3=0;e2=1;
  1107.         switch(*analyseurs)
  1108.       {
  1109.           case '+':
  1110.           case '-': analyseurs++;niveau++;break;
  1111.           default: niveau--;
  1112.       }
  1113.         break;
  1114.       case 1: 
  1115.         if(!e2) {niveau++;break;}
  1116.         e2=0;e1=1;
  1117.         switch(*analyseurs)
  1118.       {
  1119.           case '<': analyseurs++;
  1120.             switch(*analyseurs)
  1121.           {
  1122.               case '=':
  1123.               case '>': analyseurs++;niveau++;break;
  1124.         default : niveau++;break;
  1125.           }
  1126.             break;
  1127.           case '>': analyseurs++;
  1128.             if((*analyseurs)=='=') analyseurs++;
  1129.             niveau++; break;
  1130.           case '=': 
  1131.           case '!': 
  1132.             if((analyseurs[1])=='=') {analyseurs+=2;niveau++;}
  1133.             break;
  1134.           default: niveau--;
  1135.       }
  1136.         break;
  1137.       case 0: 
  1138.         if(!e1) {niveau++;break;}
  1139.         e1=0;
  1140.         switch(*analyseurs)
  1141.       {
  1142.           case '&': analyseurs++;if(*analyseurs=='&') analyseurs++;niveau++;break;
  1143.           case '|': analyseurs++;if(*analyseurs=='|') analyseurs++;niveau++;break;
  1144.           default: return;
  1145.       }
  1146.       }
  1147. }
  1148.  
  1149. void skipfacteur()
  1150. {
  1151.   if (((*analyseurs)=='+') || ((*analyseurs)=='-')) analyseurs++;
  1152.   skiptruc();
  1153.   for (;;) switch(*analyseurs)
  1154.     {
  1155.     case '^': analyseurs++;skipfacteur(); break;
  1156.     case '~': 
  1157.     case '_':
  1158.     case '\'': analyseurs++;break;
  1159.     case '[': 
  1160.       analyseurs++;
  1161.       if(*analyseurs == ',') {analyseurs++;skipexpr();}
  1162.       else
  1163.     {
  1164.       skipexpr();
  1165.       if(*analyseurs==',')
  1166.         {
  1167.           analyseurs++;if(*analyseurs != ']') skipexpr();
  1168.         }
  1169.     }
  1170.       match(']');break;
  1171.     case '!': analyseurs++;if((*analyseurs)!='=') break; else analyseurs--;
  1172.     default: return;
  1173.     }
  1174. }
  1175.  
  1176. void skiptruc()
  1177. {
  1178.   long n=0,p=0,m=1;
  1179.   
  1180.   if (isalpha(*analyseurs)) {skipidentifier(); return;}
  1181.   if (isdigit(*analyseurs) || (*analyseurs=='.')) {skipconstante(); return;}
  1182.   switch(*analyseurs++)
  1183.     {
  1184.     case '(': skipexpr();match(')');return;
  1185.     case '[': if (*analyseurs!=']') 
  1186.       {do {n++; skipexpr();} while (*analyseurs++==',');analyseurs--;}
  1187.       switch (*analyseurs++)
  1188.     {
  1189.         case ']': return;
  1190.         case ';': m=n;do {n++; skipexpr();} while (*analyseurs++!=']');
  1191.           if (n % m) err(recter1);
  1192.           return;
  1193.         default: err(vectmater1);
  1194.     }
  1195.     case '%':
  1196.       p=0;while((*analyseurs)=='`') {analyseurs++;p++;}
  1197.       if(p>tglobal) err(referer1);
  1198.       if(p) return;
  1199.       while (isdigit(*analyseurs)) p = 10*p + *analyseurs++ - '0';
  1200.       if(p>tglobal) err(referer1);
  1201.       return;
  1202.     }
  1203.   err(caracer1,analyseurs-1);
  1204. }
  1205.  
  1206. void skipidentifier()
  1207. {
  1208.   long nparam, i, m;
  1209.   entree *ep, **p;
  1210.   char *ch1;
  1211.   GEN arg;
  1212.  
  1213.   ep = skipentry();
  1214.   if (ep->valence < 100) /* fonctions predefinies */
  1215.     {
  1216.       if (!ep->valence && (*analyseurs != '(')) return;
  1217.       match('(');
  1218.       switch(ep->valence)
  1219.     {
  1220.     case 0:
  1221.     case 56: break;
  1222.     case 1:
  1223.     case 10:
  1224.     case 11:
  1225.     case 13:
  1226.     case 15:
  1227.     case 61: skipexpr(); break;
  1228.     case 60: arg=expr();if(typ(arg)!=1) err(caseer);
  1229.       m=itos(arg);if((m>=100)||(m<0)) err(labeler);
  1230.       labellist[m]=analyseurs;break;
  1231.     case 51: case 52: case 53: case 54: case 55:
  1232.       if (*analyseurs != ')') for(;;)
  1233.         {
  1234.           if (*analyseurs == '"')
  1235.         {
  1236.           analyseurs++;
  1237.           while ((*analyseurs)&&(*analyseurs!='"')) analyseurs++;
  1238.           match('"');
  1239.         }
  1240.           else skipexpr();
  1241.           if (*analyseurs == ')') break;
  1242.           match(',');
  1243.         }
  1244.       break;
  1245.     case 2:
  1246.     case 12:
  1247.     case 14:
  1248.     case 20:
  1249.     case 21:
  1250.     case 23:
  1251.     case 24:
  1252.     case 25:
  1253.     case 28:
  1254.     case 29: skipexpr(); match(','); skipexpr(); break;
  1255.     case 22: skipexpr(); match(',');
  1256.       if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  1257.       ep = skipentry(); if (ep->valence!=200) err(varer1,analyseurs);
  1258.       match(','); skipexpr(); break;
  1259.     case 27: if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  1260.       ep = skipentry(); match('='); if (ep->valence!=200) err(varer1,analyseurs);
  1261.       skipexpr(); match(','); skipexpr(); break;
  1262.     case 3:
  1263.     case 26: 
  1264.     case 30:
  1265.     case 31:
  1266.     case 32:
  1267.     case 33: skipexpr();match(',');skipexpr();match(',');skipexpr();
  1268.       break;
  1269.     case 37: if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  1270.       ep = skipentry(); match('='); if (ep->valence!=200) err(varer1,analyseurs);
  1271.       skipexpr(); match(','); skipexpr(); match(','); skipexpr();break;
  1272.     case 4: skipexpr();match(',');skipexpr();match(',');skipexpr();
  1273.       match(',');skipexpr();break;
  1274.     case 48: skipexpr(); match(',');
  1275.       if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  1276.       ep = skipentry(); match('='); if (ep->valence!=200) err(varer1,analyseurs);
  1277.       skipexpr(); match(','); skipexpr(); match(','); skipexpr();break;
  1278.     case 49: skipexpr(); match(','); skipexpr(); match(',');
  1279.       if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  1280.       ep = skipentry(); if (ep->valence!=200) err(varer1,analyseurs);
  1281.       match(',');if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  1282.       ep = skipentry(); if (ep->valence!=200) err(varer1,analyseurs);
  1283.       match(','); skipexpr(); break;
  1284.     case 50: skiptruc();
  1285.       if (*analyseurs++=='^') skipfacteur();else analyseurs--;
  1286.       break;
  1287.     case 80: skipexpr(); match(','); skipseq(); match(','); skipseq(); break;
  1288.     case 81:
  1289.     case 82: skipexpr(); match(','); skipseq(); break;
  1290.     case 83: if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  1291.       ep = skipentry(); match('='); if (ep->valence!=200) err(varer1,analyseurs);
  1292.       skipexpr(); match(','); skipexpr(); match(','); skipseq(); break;
  1293.     case 84: skipexpr(); match(',');
  1294.       if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  1295.       ep = skipentry(); if (ep->valence!=200) err(varer1,analyseurs);
  1296.       match(','); skipseq(); break;
  1297.     case 85: if(!isalpha(*analyseurs)) err(killer1);
  1298.       ep = skipentry(); if (ep->valence<100) err(killer1);
  1299.       break;
  1300.     case 86: if(!isalpha(*analyseurs)) err(varer1,analyseurs);
  1301.       ep = skipentry(); match('='); if (ep->valence!=200) err(varer1,analyseurs);
  1302.       skipexpr();match(',');skipexpr();match(',');skipexpr();match(',');skipseq();break;
  1303.     default: err(valencer1);
  1304.     }
  1305.       match(')');
  1306.       return;
  1307.     }
  1308.   switch (ep->valence)
  1309.     {
  1310.     case 200: /* variables */
  1311.       if((*analyseurs)=='[')
  1312.     {
  1313.       analyseurs++;
  1314.       if(*analyseurs == ',') {analyseurs++;skipexpr();}
  1315.       else
  1316.         {
  1317.           skipexpr();
  1318.           if(*analyseurs == ',')
  1319.         {
  1320.           analyseurs++;if(*analyseurs != ']') skipexpr();
  1321.         }
  1322.         }
  1323.       match(']');
  1324.     }
  1325.       if(((*analyseurs)=='=')&&(*(analyseurs+1)!='=')) 
  1326.     {
  1327.       analyseurs++;skipexpr(); 
  1328.     }
  1329.       return;
  1330.       
  1331.     case 100: /* fonctions utilisateur */
  1332.       ch1 = analyseurs;
  1333.       match('(');
  1334.       p = (entree **)ep->value;
  1335.       nparam = (long)*p++;
  1336.       i = 0;
  1337.       for(i = 0; (i < nparam) && (*analyseurs != ')'); i++)
  1338.     {
  1339.       if (i) match(',');
  1340.       skipexpr();
  1341.     }
  1342.       if ((*analyseurs==')') && ((analyseurs[1] != '=') || (analyseurs[2] == '='))) {analyseurs++; return;}
  1343.       while (*analyseurs == ',') {analyseurs++; skipexpr();}
  1344.       match(')');
  1345.       if ((*analyseurs != '=') || (analyseurs[1] == '=')) err(nparamer1);
  1346.       analyseurs = ch1;
  1347.       
  1348.     case 101: /* nouvelle fonction */
  1349.       
  1350.       match('(');
  1351.       for(nparam = 0; *analyseurs != ')'; nparam++)
  1352.     {
  1353.       if (nparam) match(',');
  1354.       skipexpr();
  1355.     };
  1356.       match(')');
  1357.       if (*analyseurs == '=') {analyseurs++; skipseq();}
  1358.       return;
  1359.       
  1360.     default: err(valencer1);
  1361.     }
  1362. }
  1363.  
  1364. void skipconstante()
  1365. {  
  1366.   while (isdigit(*analyseurs)) analyseurs++;
  1367.   if ((*analyseurs!='.')&&(*analyseurs!='e')&&(*analyseurs!='E')) return;
  1368.   if (*analyseurs=='.') analyseurs++;
  1369.   while (isdigit(*analyseurs)) analyseurs++;
  1370.   if ((*analyseurs=='e') || (*analyseurs=='E'))
  1371.     {
  1372.       analyseurs++;
  1373.       if (((*analyseurs)=='+') || ((*analyseurs)=='-')) analyseurs++;
  1374.       while (isdigit(*analyseurs)) analyseurs++;
  1375.     }
  1376. }
  1377.  
  1378. entree fake101 = {"",101,0,0};
  1379. entree fake200 = {"",200,0,0};
  1380.  
  1381. entree *skipentry()
  1382. {
  1383.   char *u, *v, *olds = analyseurs;
  1384.   long n;
  1385.   entree *ep;
  1386.   
  1387.   for(n = 0; isalnum(*analyseurs); analyseurs++) n = n << 1 ^ *analyseurs;
  1388.   if (n < 0) n = -n; n %= TBLSZ;
  1389.   for(ep = hashtable[n]; ep; ep = ep->next)
  1390.     {
  1391.       for(u = ep->name, v = olds; (*u) && *u == *v; u++, v++);
  1392.       if (!*u && (v == analyseurs)) return ep;
  1393.     }
  1394.   return (*analyseurs == '(') ? &fake101 : &fake200;
  1395. }
  1396.